﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Pages/Site1.Master" AutoEventWireup="true" CodeBehind="Teacher_Teach_Search.aspx.cs" Inherits="ES_Project.Pages.WebForm32" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link type="text/css" href="js/js/css/ui-lightness/jquery-ui-1.8.10.custom.css" rel="stylesheet" />	
<link type="text/css" href="js/js/css/jquery.timeentry.css" rel="stylesheet" />
  <script type="text/javascript" src="js/js/jquery-1.4.4.min.js"></script>
  <script type="text/javascript" src="js/js/jquery-ui-1.8.10.offset.datepicker.min.js"></script>
  <script type="text/javascript" src="js/js/jquery.datepick-th.js"></script>
  <script type="text/javascript" src="js/js/jquery-ui-timepicker-addon.js"></script>
  <script type="text/javascript" src="js/js/jquery.timeentry.js"></script>
  <script type="text/javascript" src="js/js/jquery.timeentry.min.js"></script>
  <script type="text/javascript" src="js/js/jquery.timeentry.pack.js"></script>
    <style type="text/css">

/* Overide css code กำหนดความกว้างของปฏิทินและอื่นๆ */ 
.ui-datepicker{

	width:170px;

	font-family:tahoma;

	font-size:11px;

	text-align:center;

}
/* css for timepicker */
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
</style>
    <style type="text/css">
        table{font-size:small;
margin-top: 0px;
    color: #000000;
}
TABLE {
	MARGIN-BOTTOM: 0px
}
        .style3
        {
            width: 59px;
        }
        .style4
        {
            width: 1167px;
        }
    .DNNAlignright {
	TEXT-ALIGN: right
}
select,input,button,textarea,button{font:99% arial,helvetica,clean,sans-serif;}
INPUT {
	FONT: 700 small normal normal arial, helvetica, clean, sans-serif; COLOR: #057cc4; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px;
    text-align: left;
}
SELECT {
	FONT: 700 small normal normal arial, helvetica, clean, sans-serif; COLOR: #057cc4; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px
}
TEXTAREA {
	FONT: 700 small normal normal arial, helvetica, clean, sans-serif; COLOR: #057cc4; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px
}
TH {
	FONT-FAMILY: Tahoma, Arial, Helvetica; COLOR: #003366; FONT-SIZE: 12px; VERTICAL-ALIGN: baseline; FONT-WEIGHT: bold
}
        .style15
        {
            width: 100%;
        }
        .style19
        {
            width: 47px;
        }
        .style20
        {
            width: 1167px;
            font-size: small;
        }
        .style30
        {
            font-size: small;
            font-weight: bold;
            text-align: right;
            width: 117px;
        }
        .style31
        {
            width: 201px;
        }
        .style33
        {
            font-size: small;
            text-align: right;
            width: 141px;
            font-weight: 700;
        }
        .style34
        {
            width: 208px;
            font-weight: 700;
        }
        .style37
        {
            font-size: small;
            text-align: right;
            width: 262px;
            font-weight: 700;
        }
        .style38
        {
            width: 289px;
            font-weight: 700;
        }
        .style39
        {
            width: 1167px;
            font-size: 12pt;
        }
        .style40
        {
            width: 59px;
            height: 21px;
        }
        .style41
        {
            width: 1167px;
            height: 21px;
        }
        .style42
        {
            width: 47px;
            height: 21px;
        }
    </style>
    
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"/>
        <script type="text/javascript">

            $(Sys.Application.add_load(function () {
            
               // alert();
                $("#ContentPlaceHolder1_empCode").focusout(function () {
                  //  alert("fdfdf");
                    document.getElementById('ContentPlaceHolder1_CMD_EmpCode').click();
                })
                $('#ContentPlaceHolder1_empClsStart').timepicker({});

                $("#ContentPlaceHolder1_clsRegCode").focusout(function () {
                    //  alert("fdfdf");
                    document.getElementById('ContentPlaceHolder1_CMD_CourseCode').click();
                })
                
            }));
    </script>
    <script type ="text/javascript">
        function gotoButton(e) {
            var keyPressed;
            if (window.event) {
                keyPressed = window.event.keyCode; // IE
                if (keyPressed == 13) {


                    //  document.getElementById("CMD_AgentCode").focus();
                    document.getElementById('ContentPlaceHolder1_CMD_EmpCode').click();
                }

            } else {
                keyPressed = e.which; // Firefox
                if (keyPressed == 13) {
                    document.getElementById('ContentPlaceHolder1_CMD_EmpCode').click();
                    //document.getElementById("CMD_AgentCode").focus();
                }

            }
        }

        function chButton() {

            if (document.getElementById("ContentPlaceHolder1_empCode").value == "") {
                 alert("กรุณาระบุรหัสครูเพื่อค้นหาครูผู้สอน");
                //document.getElementById("AgentCode").focus();
                return (false);
            }
            if (document.getElementById("ContentPlaceHolder1_empCode").value.length != 2) {
                   //alert("กรุณาระบุรหัสตัวแทนให้ครบ 6 หลัก");
                document.getElementById("ContentPlaceHolder1_empId").focus();
                return (false);
            }

            

            return true;

        } function gotoButton2(e) {
            var keyPressed;
            if (window.event) {
                keyPressed = window.event.keyCode; // IE
                if (keyPressed == 13) {


                    //  document.getElementById("CMD_AgentCode").focus();
                    document.getElementById('ContentPlaceHolder1_CMD_CourseCode').click();
                }

            } else {
                keyPressed = e.which; // Firefox
                if (keyPressed == 13) {
                    document.getElementById('ContentPlaceHolder1_CMD_CourseCode').click();
                    //document.getElementById("CMD_AgentCode").focus();
                }

            }
        }

        function chButton2() {

            if (document.getElementById("ContentPlaceHolder1_clsRegCode").value == "") {
                alert("กรุณาระบุรหัสครูเพื่อค้นหาครูผู้สอน");
                //document.getElementById("AgentCode").focus();
                return (false);
            }
            if (document.getElementById("ContentPlaceHolder1_clsRegCode").value.length != 2) {
                //alert("กรุณาระบุรหัสตัวแทนให้ครบ 6 หลัก");
                document.getElementById("ContentPlaceHolder1_clsRegId").focus();
                return (false);
            }



            return true;

        }
        function calculateHour() {
            var a = document.getElementById("ContentPlaceHolder1_empClsStart").value;
            var b = document.getElementById("ContentPlaceHolder1_empClsEnd").value;
            var courseTime = document.getElementById("ContentPlaceHolder1_clsCourseTime").value;
            //alert(document.getElementById("ContentPlaceHolder1_clsCourseTime").value);
            
                
                var c = a.substring(0, 2);
                var d = a.substring(3, 5);
            
             
                var e = b.substring(0, 2);
                var f = b.substring(3, 5);
            
                var front = eval(parseInt(e) - parseInt(c));
                var back = eval(parseInt(f) -  parseInt(d));
                if (isNaN(front) || isNaN(back)) {
                    document.getElementById("ContentPlaceHolder1_empClsHours").value = '0.0';
                }
                else if (front < 0 || back < 0){

                    document.getElementById("ContentPlaceHolder1_empClsHours").value = '0.0';
                    var zero = '0.0';
                }else{
                    document.getElementById("ContentPlaceHolder1_empClsHours").value = front + '.' + back;
                    var timeCal = front + '.' + back;
                    
                    //alert(courseTime);
                    //alert(timeCal);
                    var totalCal = eval(parseFloat(courseTime) * parseFloat(timeCal));
                    document.getElementById("ContentPlaceHolder1_empClsTotalHours").value = Math.round(totalCal);
                }
            
            //alert(a.substring(0, 2));
            //alert(a.substring(3, 5));

            }
            function ClearDropDown() {
                //alert();
                document.getElementById("ContentPlaceHolder1_myDDL1").value = "";
            }

            function validate() {
                // alert(document.getElementById("ContentPlaceHolder1_empCode").value);
                if (document.getElementById("ContentPlaceHolder1_empCode").value == "") {
                    alert('กรุณากรอกรหัสครู');
                    return false;
                }
                if (document.getElementById("ContentPlaceHolder1_clsRegCode").value == "") {
                    alert('กรุณากรอกรหัสวิชาที่ครูสอน');
                    return false;
                }


                return true;

            }
        
        
    </script> 
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table cellpadding="0" cellspacing="0" class="style2">
                <tr>
                    <td class="style3">
                        &nbsp;</td>
                    <td class="style39">
                        <strong>ค้นหาข้อมูลตารางสอนของครู</strong></td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style40">
                        </td>
                    <td class="style41">
                        </td>
                    <td class="style42">
                        </td>
                </tr>
                <tr>
                    <td class="style3">
                        &nbsp;</td>
                    <td class="style4">
                        <table cellpadding="0" cellspacing="0" class="style15">
                            <tr>
                                <td class="style37">
                                    <b>รหัสครู :</b></td>
                                <td class="style34">
                                    
                                    <asp:TextBox ID="empCode" runat="server"    Width="141px" 
                                       MaxLength="6" ></asp:TextBox>
                                    <asp:Button ID="CMD_EmpCode" runat="server"  
                                      Text="ค้นหา" CssClass="stylebutton" style="display:none"/>
                              
                                <asp:Label ID="empId" runat="server"  style="display:none"></asp:Label>
                                <asp:Label ID="clsRegDetailId" runat="server"  style="display:none"></asp:Label>
                                <asp:Label ID="empClsMastId" runat="server"  style="display:none"></asp:Label>
                                <asp:TextBox ID="clsCourseTime" runat="server"  style="display:none"></asp:TextBox>
                                </td>
                                <td class="style33">
                                    <b>ชื่อครู :</b></td>
                                <td class="style31">
                                    <asp:TextBox ID="empName" runat="server" Width="141px"  ></asp:TextBox>
                                </td>
                                <td class="style30">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style37">
                                    &nbsp;</td>
                                <td class="style34">
                                    &nbsp;</td>
                                <td class="style33">
                                    &nbsp;</td>
                                <td class="style31">
                                    &nbsp;</td>
                                <td class="style30">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style37">
                                    <strong>รหัสวิชา : </strong>
                                </td>
                                <td class="style34">
                                    <asp:TextBox ID="clsRegCode" runat="server"  Width="141px"></asp:TextBox>
                                </td>
                                <td class="style33">
                                    ชื่อวิชา :</td>
                                <td class="style31">
                                    <asp:TextBox ID="clsName" runat="server" Width="141px"></asp:TextBox>
                                </td>
                                <td class="style30">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style37">
                                    &nbsp;</td>
                                <td class="style34">
                                    &nbsp;</td>
                                <td class="style33">
                                    &nbsp;</td>
                                <td class="style31">
                                    &nbsp;</td>
                                <td class="style30">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style37">
                                    <b>วันที่สอน :</b></td>
                                <td class="style34">
                                    <asp:TextBox ID="empClsDay" runat="server" Width="141px"></asp:TextBox>
                                </td>
                                <td class="style33">
                                    &nbsp;</td>
                                <td class="style31">
                                    <script type="text/javascript">

                                        $(Sys.Application.add_load(function () {

                                            //alert();
                                            //$('#ContentPlaceHolder1_empClsStart').timepicker({});
                                            $('#ContentPlaceHolder1_empClsStart').timeEntry({ show24Hours: true });
                                        }));
                                    </script>
                                </td>
                                <td class="style30">
                                    &nbsp;</td>
                                <td>
                                    <script type="text/javascript">

                                        $(Sys.Application.add_load(function () {

                                            //alert();
                                            //$('#ContentPlaceHolder1_empClsStart').timepicker({});
                                            $('#ContentPlaceHolder1_empClsEnd').timeEntry({ show24Hours: true });
                                        }));
                                    </script>
                                </td>
                            </tr>
                            <tr>
                                <td class="style37">
                                    &nbsp;</td>
                                <td class="style34">
                                    &nbsp;</td>
                                <td class="style33">
                                    &nbsp;</td>
                                <td class="style31">
                                    &nbsp;</td>
                                <td class="style30">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style37">
                                    &nbsp;</td>
                                <td class="style34">
                                    &nbsp;</td>
                                <td class="style33">
                                    &nbsp;</td>
                                <td class="style31">
                                    &nbsp;</td>
                                <td class="style30">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style37">
                                    &nbsp;</td>
                                <td class="style34">
                                    <asp:Button ID="CMD_SEARCH" runat="server" Text="  ค้นหา  " Width="60px" 
                                        OnClick="CMD_SEARCH_Click" />
                                    <%--&nbsp;<asp:Button ID="CMD_EDIT" runat="server" Text="แก้ไข" 
                                        OnClick="CMD_INSERT_Click"/>--%>
                                    &nbsp;<asp:Button ID="CMD_CLEAR" runat="server" Text="  เคลียร์  " Width="60px" 
                                        OnClick="CMD_CLEAR_Click" />
                                </td>
                                <td class="style33">
                                    &nbsp;</td>
                                <td class="style31">
                                    &nbsp;</td>
                                <td class="style30">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                        </table>
                    </td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style3">
                        &nbsp;</td>
                    <td class="style20">
                        &nbsp;</td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style3">
                        &nbsp;</td>
                    <td class="style4">
                        &nbsp;<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                            border="1" CellPadding="4" CssClass="DataGrid_Footer" ForeColor="#333333" 
                            GridLines="None" Width="100%" OnSelectedIndexChanging = "GridView2_SelectedIndexChanging"
                            DataKeyNames="emp_cls_mast_id" OnRowDeleting="GridView4_RowDeleting" OnRowDataBound = "GridView4_RowDataBound">
                            <AlternatingRowStyle BackColor="PaleGoldenrod" />
                            <Columns>
                                <asp:TemplateField HeaderText="ลำดับ">
                                    <HeaderTemplate>
                                        ลำดับ
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                       <%#Container.DataItemIndex+1 %>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField Visible="false">
                                    <ItemTemplate>
                                       <asp:HiddenField ID="HiddenField3" runat="server" Visible="false"
                                          Value='<%# Eval("emp_cls_mast_id") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="emp_code" HeaderText="รหัสครู"
                                    ItemStyle-HorizontalAlign="left">
                                    <ItemStyle HorizontalAlign="Left" /> 
                                </asp:BoundField >
                                <asp:BoundField DataField="emp_name" HeaderText="ชื่อ-นามสกุลครู"
                                    ItemStyle-HorizontalAlign="left">
                                    <ItemStyle HorizontalAlign="Left" /> 
                                </asp:BoundField >
                                <asp:BoundField DataField="emp_cls_day" HeaderText="วันที่สอน"
                                    ItemStyle-HorizontalAlign="left">
                                    <ItemStyle HorizontalAlign="Left" /> 
                                </asp:BoundField >
                                <asp:BoundField DataField="emp_cls_start" HeaderText="เวลาเริ่ม"
                                    ItemStyle-HorizontalAlign="left">
                                    <ItemStyle HorizontalAlign="Left" /> 
                                </asp:BoundField >
                                <asp:BoundField DataField="emp_cls_end" HeaderText="เวลาสิ้นสุด"
                                    ItemStyle-HorizontalAlign="left">
                                    <ItemStyle HorizontalAlign="Left" /> 
                                </asp:BoundField >
                                <asp:BoundField DataField="emp_cls_hours" HeaderText="รวม"
                                    ItemStyle-HorizontalAlign="left">
                                    <ItemStyle HorizontalAlign="Left" /> 
                                </asp:BoundField >
                                <asp:BoundField DataField="emp_cls_total_hours" HeaderText="รวมทั้งหมด"
                                    ItemStyle-HorizontalAlign="left">
                                    <ItemStyle HorizontalAlign="Left" /> 
                                </asp:BoundField >
                                <asp:BoundField DataField="name_course" HeaderText="วิชา(ชม.)"
                                    ItemStyle-HorizontalAlign="left">
                                    <ItemStyle HorizontalAlign="Left" /> 
                                </asp:BoundField >
                                <asp:TemplateField HeaderText="แก้ไข" ItemStyle-HorizontalAlign="left">
                                            <ItemStyle HorizontalAlign="Left" />  
                                               <ItemTemplate>
                                                    <asp:HyperLink  ID="edit" runat="server"  ImageUrl="~/Pages/images/icon_15.gif"  Text ='<%# Eval("emp_cls_mast_id") %>' ></asp:HyperLink>
                                               </ItemTemplate>
                                               
                                               <ItemStyle HorizontalAlign="Center" />
                                           </asp:TemplateField>
                                <%--<asp:CommandField ButtonType="Image" HeaderText="แก้ไข" 
                                    ItemStyle-HorizontalAlign="Center" 
                                    SelectImageUrl="~/Pages/images/icon_15.gif" ShowSelectButton="True" >
                                    <ItemStyle HorizontalAlign="Center" />
                                </asp:CommandField>--%>
                                <asp:CommandField ButtonType="Image" HeaderText="ลบ" 
                                              ItemStyle-HorizontalAlign="Center" 
                                              SelectImageUrl="~/Pages/images/icon_del.gif"  
                                    ShowDeleteButton="True" DeleteImageUrl="~/Pages/images/icon_del.gif" 
                                    DeleteText="" >
                                              <ItemStyle HorizontalAlign="Center" />
                                </asp:CommandField>
                            </Columns>
                            <EditRowStyle BackColor="#2461BF" />
                            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                            <RowStyle BackColor="#EFF3FB" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                            <SortedAscendingCellStyle BackColor="#F5F7FB" />
                            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                            <SortedDescendingCellStyle BackColor="#E9EBEF" />
                            <SortedDescendingHeaderStyle BackColor="#4870BE" />
                        </asp:GridView>
                    </td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style3">
                        &nbsp;</td>
                    <td class="style4">
                        &nbsp;</td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style3">
                        &nbsp;</td>
                    <td class="style4">
                        &nbsp;</td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style3">
                        &nbsp;</td>
                    <td class="style4">
                        &nbsp;</td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style3">
                        &nbsp;</td>
                    <td class="style4">
                        &nbsp;</td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
     <br />
   
</asp:Content>